Global Constants vs. Global Variables

1.   A constant which is needed in more than one function can be declared a global constant by declaring it a constant, initializing it and placing it outside of the body of all the functions, including the main function.

 

2.   According to standard practice global constant declarations are placed after preprocessor directives and before function prototypes.

 

3.   The value of a global constant can be accessed by all of the functions.

 

4.   It is possible to declare global variables which are accessible to all the functions.

 

5.   Global variable are declare just like any ordinary variable, except that the declaration must be placed outside the body of all the functions, preferably after preprocessor directives and before function prototypes.

 

6.   However, there is seldom any need to use global variables. Global variables often make a program hard to read and debugged, and are often the signs of very bad program designs. You should not use.